package com.shao;

import com.shao.utils.zookeeper.ZookeeperNode;
import com.shao.utils.zookeeper.ZookeeperUtils;
import org.apache.zookeeper.*;

import java.util.List;

/**
 * @author PaoFu
 * @version 1.0
 * @data 2025/4/8 15:17
 */
public class Application {

    public static void main(String[] args) {
        // 创建Zookeeper
        ZooKeeper zookeeper = ZookeeperUtils.createZookeeper();
        // 创建节点目录和数据
        String basePath = "/zk";
        ZookeeperNode basePathNode = new ZookeeperNode(basePath, null);
        ZookeeperNode providersPathNode = new ZookeeperNode(basePath + "/providers", null);
        ZookeeperNode consumersPathNode = new ZookeeperNode(basePath + "/consumers", null);
        List.of(basePathNode, providersPathNode, consumersPathNode).forEach(node -> {
            ZookeeperUtils.createZookeeperNode(zookeeper, null, node, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        });
        // 关闭Zookeeper
        ZookeeperUtils.closeZookeeper(zookeeper);
    }
}
